package com.chuantou.yuba.api.to;

import java.util.ArrayList;

import com.google.gson.annotations.SerializedName;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

public class FishingShopTO implements Parcelable {
	/** 经销商 */
	public static final int TYPE_JINGXIAOSHANG = 1;
	/** 品牌商 **/
	public static final int TYPE_PINPAISHANG = 2;
	/*** 网店 */
	public static final int TYPE_WANGDIAN = 3;

	@SerializedName("active")
	private int active;
	// 状态名称
	@SerializedName("active_name")
	private String activeName;
	// 渔具店ID
	@SerializedName("id")
	private long id = -1;
	// 渔具店类型
	@SerializedName("type")
	private String typeName;
	// 渔具店类型ID
	@SerializedName("type_num")
	private int typeId;
	// 渔具店名字
	@SerializedName("name")
	private String name;
	// 首字母
	@SerializedName("letter")
	private String letter;
	// 封面
	@SerializedName("cover")
	private String cover;
	// 介绍
	@SerializedName("content")
	private String content;
	// 店铺地址
	@SerializedName("address")
	private String address;
	// 联系人
	@SerializedName("contact")
	private String contact;
	// 联系人手机
	@SerializedName("phone")
	private String phone;
	// 网店地址
	@SerializedName("shop_url")
	private String shopUrl;
	// 时间，单位秒
	@SerializedName("dateline")
	private long addtime;
	// 距离
	@SerializedName("distance")
	private double distance;
	// 图片，收藏列表会有，周边不会有
	@SerializedName("img")
	private String image;
	// 名称，收藏列表中名称为该栏
	@SerializedName("title")
	private String title;
	// 经纬度
	@SerializedName("location")
	private String location;

	// 省份ID
	@SerializedName("state_id")
	private String stateId;
	// 省份名称
	@SerializedName("state")
	private String stateName;
	// 城市名称
	@SerializedName("city")
	private String cityName;
	// 城市ID
	@SerializedName("city_id")
	private String cityId;
	// 图片
	@SerializedName("photos")
	private ArrayList<ImageTO> images;

	public FishingShopTO() {
	}

	public FishingShopTO(Parcel source) {
		this.id = source.readLong();
		this.typeName = source.readString();
		this.typeId = source.readInt();
		this.name = source.readString();
		this.letter = source.readString();
		this.cover = source.readString();
		this.content = source.readString();
		this.address = source.readString();
		this.contact = source.readString();
		this.phone = source.readString();
		this.shopUrl = source.readString();
		this.addtime = source.readLong();
		this.distance = source.readDouble();
		this.image = source.readString();
		this.title = source.readString();
		this.location = source.readString();
		this.stateId = source.readString();
		this.stateName = source.readString();
		this.cityName = source.readString();
		this.cityId = source.readString();
		this.active = source.readInt();
		this.activeName = source.readString();
		this.images = new ArrayList<ImageTO>();
		source.readTypedList(images, ImageTO.CREATOR);
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeLong(this.id);
		dest.writeString(this.typeName);
		dest.writeInt(this.typeId);
		dest.writeString(this.name);
		dest.writeString(this.letter);
		dest.writeString(this.cover);
		dest.writeString(this.content);
		dest.writeString(this.address);
		dest.writeString(this.contact);
		dest.writeString(this.phone);
		dest.writeString(this.shopUrl);
		dest.writeLong(this.addtime);
		dest.writeDouble(this.distance);
		dest.writeString(image);
		dest.writeString(title);
		dest.writeString(location);
		dest.writeString(stateId);
		dest.writeString(stateName);
		dest.writeString(cityName);
		dest.writeString(cityId);
		dest.writeInt(active);
		dest.writeString(activeName);
		dest.writeTypedList(this.images);
	}

	public static final Creator<FishingShopTO> CREATOR = new Creator<FishingShopTO>() {

		@Override
		public FishingShopTO[] newArray(int size) {
			return new FishingShopTO[size];
		}

		@Override
		public FishingShopTO createFromParcel(Parcel source) {
			return new FishingShopTO(source);
		}
	};

	public boolean isActive() {
		return active == 1;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public int getTypeId() {
		return typeId;
	}

	public void setTypeId(int typeId) {
		this.typeId = typeId;
	}

	public String getName() {
		return TextUtils.isEmpty(name) ? title : name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLetter() {
		return TextUtils.isEmpty(letter) ? "#" : letter;
	}

	public void setLetter(String letter) {
		this.letter = letter;
	}

	public String getCover() {
		String dstCover = TextUtils.isEmpty(cover) ? image : cover;
		if (TextUtils.isEmpty(dstCover)) {
			if (images != null && !images.isEmpty()) {
				dstCover = images.get(0).getUrl();
			}
		}
		return dstCover;
	}

	public void setCover(String cover) {
		this.cover = cover;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getShopUrl() {
		return shopUrl;
	}

	public void setShopUrl(String shopUrl) {
		this.shopUrl = shopUrl;
	}

	public long getAddtime() {
		return addtime;
	}

	public void setAddtime(long addtime) {
		this.addtime = addtime;
	}

	public double getDistance() {
		return distance;
	}

	public void setDistance(double distance) {
		this.distance = distance;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getStateId() {
		return stateId;
	}

	public void setStateId(String stateId) {
		this.stateId = stateId;
	}

	public String getStateName() {
		return stateName;
	}

	public void setStateName(String stateName) {
		this.stateName = stateName;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public String getCityId() {
		return cityId;
	}

	public void setCityId(String cityId) {
		this.cityId = cityId;
	}

	public int getActive() {
		return active;
	}

	public void setActive(int active) {
		this.active = active;
	}

	public String getActiveName() {
		return activeName;
	}

	public void setActiveName(String activeName) {
		this.activeName = activeName;
	}

	public ArrayList<ImageTO> getImages() {
		return images;
	}

	public void setImages(ArrayList<ImageTO> images) {
		this.images = images;
	}

}
